import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueDevTools from "vite-plugin-vue-devtools";
import yaml from "@rollup/plugin-yaml";

// https://vite.dev/config/
export default defineConfig({
  server: {
    host: "0.0.0.0",
    port: 5173,
    proxy: {
      // vite 项目用代理 做跨域处理是十分方便的
      "/api": {
        target: "http://localhost:9999",
        changeOrigin: true,
        rewrite: (path) => path,
      },
    },
  },
  plugins: [vue(), vueDevTools(), yaml()],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
});
